package com.jxnu.duewang.zmly.zhangHaoQi;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jxnu.duewang.zmly.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lenovo on 2016/12/7.
 */

public class Anchor_recycleriewadapter extends RecyclerView.Adapter<Anchor_recycleriewadapter.ViewHolder>{
    private List<AnchorNew> list;
    private Context context;

    public Anchor_recycleriewadapter(List<AnchorNew> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.zhqanchorlayout,parent,false);
        ViewHolder holder=new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.textView.setText(list.get(position).getTitle());
        holder.textView1.setText(list.get(position).getList().get(0).getNickname());
        Picasso.with(context)
                .load(list.get(position).getList().get(0).getSmallLogo())
                .into(holder.imageView1);
        holder.textView2.setText(list.get(position).getList().get(1).getNickname());
        Picasso.with(context)
                .load(list.get(position).getList().get(1).getSmallLogo())
                .into(holder.imageView2);
        holder.textView3.setText(list.get(position).getList().get(2).getNickname());
        Picasso.with(context)
                .load(list.get(position).getList().get(2).getSmallLogo())
                .into(holder.imageView3);

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        private TextView textView,textView1,textView2,textView3;
        private LinearLayout layoutone,layouttwo,layoutthree;
        private ImageView imageView1,imageView2,imageView3;

        public ViewHolder(View itemView) {
            super(itemView);
            textView= (TextView) itemView.findViewById(R.id.anchor_fragemnt_text1);
            layoutone = (LinearLayout) itemView.findViewById(R.id.includone);
            layouttwo= (LinearLayout) itemView.findViewById(R.id.includetwo);
            layoutthree= (LinearLayout) itemView.findViewById(R.id.includetheer);
            textView1= (TextView) layoutone.findViewById(R.id.cludetext);
            imageView1= (ImageView) layoutone.findViewById(R.id.cloudimage);
            textView2= (TextView) layouttwo.findViewById(R.id.cludetext);
            imageView2= (ImageView) layouttwo.findViewById(R.id.cloudimage);
            textView3= (TextView) layoutthree.findViewById(R.id.cludetext);
            imageView3= (ImageView) layoutthree.findViewById(R.id.cloudimage);



        }
    }
}
